﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace System.Net.DnsToolkit.Scanner {
    public static class BandwidthScheduler {

        static readonly string horloge = "2 2 2 2 2 2 2 2 10 10 10 15 15 15 15 15 15 15 15 15 10 10 2 2";
        static readonly string[] hc = horloge.Split(' ');

        public static int GetSleepTime() {
            return GetSleepTime(DateTime.Now.Hour);
        }

        static int GetSleepTime(int hour) {
            int sleeptime = int.Parse(hc[hour]);
            return 1000 / sleeptime;
        }

        static void PrintSleepTime() {

            Console.WriteLine("Hour: {0}", DateTime.Now.Hour);
            Console.WriteLine("Horloge: {0}", (hc[DateTime.Now.Hour]));

            int sleepTime = GetSleepTime();
            Console.WriteLine(sleepTime);

            for (int i = 0; i < 24; i++) {
                Console.WriteLine("Hour: {0}", i);
                Console.WriteLine("Sleep: {0}", GetSleepTime(i));
            }

        }

        static int i;
        public static void Schedule() {
            i++;
            int sleepTime = GetSleepTime();
            if ((i % sleepTime) == 0) {
                Thread.Sleep(50);
            }
        }
    }
}
